<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<link rel="stylesheet" href="<%=path%>/css/manager/users2.css">
<script type="text/javascript" src="<%=path%>/js/manager/jquery-1.8.2.js"></script>
<title>用户编辑</title>
</head>
<body>

  <input type="hidden" id="sysuserId_back" value="${back_user.sysuserId}"/>
  <input type="hidden" id="sysuserId" value="${sysuser.sysuserId}"/>
  <input type="hidden" id="sysuserType" value="${sysuser.sysuserType}"/>
  <input type="hidden" id="sysuserName" value="${sysuser.sysuserName}"/>
  <input type="hidden" id="markManage" value="${sysuser.markManage}"/>
  <input type="hidden" id="sysuserPwd_hidden" value="${sysuser.sysuserPwd}"/>
  <form  id="sform" method="post">
  </form>
	<!--
        	作者：offline
        	时间：2016-12-22
        	描述：用户管理
        -->
		<div class="bbs_mist_div1">用户管理</div>
		<div class="bbs_mist2_div2">
			<div class="news3_div2_div1">
        		<span class="news3_div2_div1_sp1"><c:if test="${sysuser.markManage==1}">添加用户</c:if><c:if test="${sysuser.markManage==2}">编辑用户</c:if></span>
        	</div>
        	<%-- <div class="users_div1">
        		<div class="users_div1_div1">帐号</div>
        		<input class="users_div1_div1_in1" type="text" id="" value="${sysuser.sysuserName}"/>
        	</div> --%>
        	<div class="users_div2">
        		<div class="users_div1_div1">密码</div>
        		<input class="users_div1_div1_in1" type="password" id="sysuserPwd" value="${sysuser.sysuserPwd}" maxlength="6"/>
        		<input class="" type="button"  value="重置" onclick="changepwd()" id="changepwd"/>
        		
        		<input type="hidden" id="markerpwd" value="0"/>
        	</div>
        	<div class="users_div8">
        		<div class="users_div1_div1">管理员等级</div>
        		<select class="users_div1_div1_in1" onchange="seltype(this)" id="seltype">
        		   <c:if test="${sysuser.sysuserType==null || sysuser.sysuserType==0}">
        				<option  value="0">普通管理员</option>
        				<option value="1">超级管理员</option>
        		   </c:if>
        		   <c:if test="${sysuser.sysuserType==1}">
        				<option value="1">超级管理员</option>
        				<option  value="0">普通管理员</option>
        		   </c:if>
        		</select>
        	</div>
        	<div class="users_div3">
        		<div class="users_div1_div1">用户姓名</div>
        		<input class="users_div1_div1_in1" type="text" id="sysuserUsername" value="${sysuser.sysuserUsername}" maxlength="20"/>
        	</div>
        	<div class="users_div4">
        		<div class="users_div1_div1">部门</div>
        		<input class="users_div1_div1_in1" type="text" id="sysuserDepartment" value="${sysuser.sysuserDepartment}" maxlength="50"/>
        	</div>
        	<div class="users_div5">
        		<div class="users_div1_div1">职位</div>
        		<input class="users_div1_div1_in1" type="text" id="sysuserJob" value="${sysuser.sysuserJob}" maxlength="50"/>
        	</div>
        	<div class="users_div6">
        		<div class="users_div1_div1">联系方式</div>
        		<input class="users_div1_div1_in1" type="text" id="sysuserTel" value="${sysuser.sysuserTel}" maxlength="20"/>
        	</div>
        	<div class="users_div7">
        		<div class="users_div1_div1">工作地点</div>
        		<input class="users_div1_div1_in1" type="text" id="sysuserAddress" value="${sysuser.sysuserAddress}" maxlength="50"/>
        	</div>
        	
        	<div class="news2_div2_div5">
        		<input class="news2_div2_div5_in1" type="button"  onclick="checksubmit()"/>
        		<input class="news2_div2_div5_in2" type="button"  onclick="cancelback()"/>
        	</div>
		</div>
</body>
 
<script type="text/javascript">
//提交验证
function checksubmit(){
	//登录账号
	var sysuserName=$("#sysuserName").val();
	var markManage=$("#markManage").val();
	//验证密码
	var password=$.trim($("#sysuserPwd").val());
	if(markManage==2){
		var markerpwd=$("#markerpwd").val();
		if(markerpwd==0){
			password="nochange";
		}else{
			if(password.length==0){
				alert("请输入6为数字密码");
				$("#sysuserPwd").focus();
				return false;
			}else if(isNaN(password)){
				alert("密码只能是数字！");
				$("#sysuserPwd").focus();
				return false;
			}
		}
	}else if(password.length==0){
		alert("请输入6为数字密码");
		$("#sysuserPwd").focus();
		return false;
	}else if(isNaN(password)){
		alert("密码只能是数字！");
		$("#sysuserPwd").focus();
		return false;
	}
	//管理员等级
	var sysuserType=$("#sysuserType").val();
	if(sysuserType!=1){
		sysuserType=0;
	}
	//用户名
	var sysuserUsername=$.trim($("#sysuserUsername").val());
	if(sysuserUsername.length==0){
		alert("用户姓名不能为空！");
		$("#sysuserUsername").focus();
		return false;
	}
	//部门
	var sysuserDepartment=$.trim($("#sysuserDepartment").val());
	if(sysuserDepartment.length==0){
		alert("部门不能为空！");
		$("#sysuserDepartment").focus();
		return false;
	}
	//职位
	var sysuserJob=$.trim($("#sysuserJob").val());
	if(sysuserJob.length==0){
		alert("职位不能为空！");
		$("#sysuserJob").focus();
		return false;
	}
	//联系方式
	var sysuserTel=$.trim($("#sysuserTel").val());
	if(sysuserTel.length==0){
		alert("联系方式不能为空！");
		$("#sysuserTel").focus();
		return false;
	}
	//地址
	var  sysuserAddress=$.trim($("#sysuserAddress").val());
	if(sysuserAddress.length==0){
		alert("地址不能为空！");
		$("#sysuserAddress").focus();
		return false;
	}
	var sysuserId=$("#sysuserId").val();
	var sysuserId_back=$("#sysuserId_back").val();
	
	$("#sform").prepend('<input type="hidden" name="adduserid" value="'+sysuserId_back+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserName" value="'+sysuserName+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserPwd" value="'+password+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserType" value="'+sysuserType+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserUsername" value="'+sysuserUsername+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserDepartment" value="'+sysuserDepartment+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserJob" value="'+sysuserJob+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserTel" value="'+sysuserTel+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserAddress" value="'+sysuserAddress+'"/>');
	$("#sform").prepend('<input type="hidden" name="sysuserId" value="'+sysuserId+'"/>');
	$("#sform").prepend('<input type="hidden" name="markManage" value="'+markManage+'"/>');
	$("#sform").attr("action","<%=path%>/userctr/managesysuser.htm");
	$("#sform").submit();
	 
}
//选择管理员类型
function seltype(obj){
	$("#sysuserType").val(obj.value);
}
//取消操作，返回列表页
function  cancelback(){
	var sysuserId_back=$("#sysuserId_back").val();
	window.location.href="<%=path%>/userctr/tosyslist.htm?adduserid="+sysuserId_back;
}
//重置密码
function changepwd(){
	var markerpwd=$("#markerpwd").val();
	if(markerpwd==0){
		markerpwd=1;
		$("#changepwd").val("取消");
		$("#sysuserPwd").val("");
		$("#sysuserPwd").focus();
	}else{
		markerpwd=0;
		$("#changepwd").val("重置");
		var sysuserPwd_hidden=$("#sysuserPwd_hidden").val();
		$("#sysuserPwd").val(sysuserPwd_hidden);
	}
	$("#markerpwd").val(markerpwd); 
}
</script>
</html>

